<!--{template admin/header}-->
<body id="homepage">
    <div id="breadcrumb">
        <ul>
            <li><img src="static/img/icons/icon_breadcrumb.png" alt="Location" /></li>
            <li><strong>位置:</strong></li>
            <li><a href="admin.php">主页</a> - 达人申请列表</li>
        </ul>
    </div>
    <div id="rightside" class="user_ability">
        <div class="contentcontainer">
            <div class="headings altheading">
                <h3>达人列表,共{$totalNum}条记录</h3>
            </div>
            <div class="contentbox">
                <div class="extrabottom">
                    <form method="get" class="form-inline" role="form" action="admin.php">
                        <div class="input-prepend">
							<span class="add-on">用户</span>
							<input class="span2" id="prependedInput" type="text" placeholder="UID" name="uid" value="$style['uid']" >
						</div>
						<select name="status" class="span2" >
							<option>--筛选达人--</option>
                            <option value="0"$style['status'][0]>申请中达人</option>
                            <option value="1"$style['status'][1]>正式达人</option>
                        </select>
                        <select name="verified" class="span2" >
                        	<option>--筛选加V用户--</option>
                            <option value="1"$style['verified'][1]>加V用户</option>
                        </select>
                        <select name="length" class="span2" >
                            <option value="20"$style['length'][20]>每页显示20个</option>
                            <option value="50"$style['length'][50]>每页显示50个</option>
                            <option value="100"$style['length'][100]>每页显示100个</option>
                        </select> 
                       <div class="input-prepend">
							<span class="add-on">页数</span>
							<input class="span1" id="prependedInput" type="text" placeholder="去到第几页" name="page" value="$style['page']" >
						</div>
                       <input type="hidden" name="ac" value="ability" />
                       <input type="hidden" value="getAbilities" name="op">
                       <button type="submit" class="btn btn-large">点击查询</button>
                    </form>
                </div>
                <div class="verifybtn">
                    <button href="#addVerifiedUser" role="button" class="btn btn-primary btn-small" data-toggle="modal">添加大V</button>
					<div id="addVerifiedUser" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
					  <form action="admin.php" method="get">
						  <div class="modal-header">
							    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
							    <h3 id="myModalLabel">添加大V用户</h3>
						  </div>
						  <div class="modal-body nav-category">
								<div class="control-group">
									<label class="control-label" for="uid">用户UID</label>
									<div class="controls">
										<input type="text" id="verifieduid" name="uid" class="input-large" placeholder="填写用户uid" value="">
									</div>
								</div>
					  	    </div>
						    <div class="modal-footer">
		                        <input type="hidden" name="ac" value="ability" />
		                        <input type="hidden" name="op" value="addVerifiedUser" />
							    <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
							    <button type="submit" class="btn btn-primary" >提交</button>
						    </div>
					  </form>
					</div>
				</div>
                <div style="clear: both;"></div>
                <table width="100%"  class="table table-striped">
                    <thead>
                        <tr>
                            <th>UID</th>
                            <th>昵称</th>
                            <th>勋章</th>
                            <th>申请/达人时间</th>
                            <th>达人类别</th>
                            <th>达人状态</th>
                            <th>加V认证</th>
                            <th>等级数</th>
                            <th>粉丝数</th>
                            <th>点滴数</th>
                            <th>话题数</th>
                            <th>被喜欢数</th>
                            <th>最后活跃时间</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <!--{loop $abilitys $value}-->
                        <tr>
                        	<td>{$value[uid]}</td>
                            <td><a href="admin.php?ac=user_profile&uid={$value[uid]}" target="_blank">{$value[user][nickname]}</a></td>
                            <td>{$value[medal_id]}</td>
                            <td>
                                <!--{date('Y-m-d H:i',$value[dateline])}-->
                            </td>
                            <td>
                            	<!--{if $value[label] == 1}-->
                            		<b>情感</b>
                            	<!--{elseif $value[label] == 5}-->
                            		<b>健康</b>
                            	<!--{elseif $value[label] == 6}-->
                            		<b>美妆</b>
                            	<!--{elseif $value[label] == 7}-->
                            		<b>星座</b>
                            	<!--{elseif $value[label] == 9}-->
                            		<b>美图</b>
                            	<!--{elseif $value[label] == 10}-->
                            		<b>搞笑</b>
                            	<!--{/if}-->
                            </td>
                            <td>
                            	<!--{if $value[status] == 0}-->
                            		申请中
                            	<!--{elseif $value[status] == 1}-->
                            		<i class="icon-ok"></i>
                            	<!--{elseif $value[status] == 2}-->
                            		不通过/过期达人
                            	<!--{/if}-->
                            </td>
                            <td>
                            	<!--{if $value[verified] == 0}-->
                            		<i class="icon-remove"></i>
                            	<!--{else}-->
                            		<i class="icon-ok"></i>
                            	<!--{/if}-->
                            </td>
                            <td>
                               {$value[level]}
                            </td>
                            <td>
                               {$value[fans_count]}
                            </td>
                            <td>
                               {$value[diaryTimes]}
                            </td>
                            <td>
                               {$value[topicTimes]}
                            </td>
                            <td>
                               {$value[likeMeTimes]}
                            </td>
                            <td>
                            	<!--{if $value[la_act] > 0}-->
                                <!--{date('Y-m-d H:i',$value[la_act])}-->
                                <!--{else}-->
                                	无活跃时间
                                <!--{/if}-->
                            </td>
                            <td>
                            	<div class="btn-group">
									  <button class="btn">管理</button>
									  <button class="btn dropdown-toggle" data-toggle="dropdown">
									    <span class="caret"></span>
									  </button>
									  <ul class="dropdown-menu">
									  	<li><a href="javascript:;" data-uid="{$value[uid]}" data-status="1" data-label="{$value['label']}" class="manageablity">添加达人</a></li>
									    <li><a href="javascript:;" data-uid="{$value[uid]}" data-status="2" data-label="{$value['label']}" class="manageablity">忽略达人</a></li>
									    <li><a href="javascript:;" data-uid="{$value[uid]}" data-status="3" data-label="{$value['label']}" class="manageablity">撤销达人</a></li>
									    <li><a href="javascript:;" data-uid="{$value[uid]}" data-verified="1" class="manageverify">认证加V</a></li>
									    <li><a href="javascript:;" data-uid="{$value[uid]}" data-verified="0" class="manageverify">取消大V</a></li>
									  </ul>
								</div>
                            </td>
                        </tr>
                        <!--{/loop}-->
                    </tbody>
                </table>
                
                <div class="extrabottom">
                    <div class="bulkactions"> $pageHtml </div>
                </div>
            </div>
        </div>


    </div>
    <!--{template admin/leftside}-->
    <!--{template admin/footer}-->
    <script type="text/javascript" language="javascript">

	// 设置达人状态
	$(document).on("click",".manageablity",function(){
		var uid = $(this).data('uid');
		var status = $(this).data('status');
		var label = $(this).data('label');
		
		$.ajax(
		        {
		            url     :   "admin.php",
		            type    :   "GET",
		            data    :   {ac : "ability", op : "setAbility", uid : uid, status : status, label : label},
		            success :   function(data)
		                        {
					            	if(data){  
					            		alert("设置成功！");
					            	}else{  
					            		alert("设置失败！");  
					            	}
				            		refresh();
		                        }
		        });
	});
	
	// 设置大V状态
	$(document).on("click",".manageverify",function(){
		var uid = $(this).data('uid');
		var verified = $(this).data('verified');
		
		$.ajax(
		        {
		            url     :   "admin.php",
		            type    :   "GET",
		            data    :   {ac : "ability", op : "setVerifiedUser", uid : uid, verified : verified},
		            success :   function(data)
		                        {
					            	if(data){  
					            		alert("设置成功！");
					            	}else{  
					            		alert("设置失败！");  
					            	}
				            		refresh();
		                        }
		        });
	});
	
	function verifyUser()
	{
		var uid  = $("#verifieduid").val();

        $.ajax(
        {
            url     :   "admin.php",
            type    :   "GET",
            data    :   {ac : "ability", op : "addVerifiedUser", uid : uid, verified : 1},
            success :   function(data)
                        {
			            	if(data){  
			            		alert("添加成功！");
			            		refresh();
			            	}else{  
			            		alert("添加失败！");  
			            	}
                        }
        });
	}

	// 刷新当前页面
	function refresh(){
	    window.location.reload();
	}
</script>